﻿using System.IO;
using FastTests;
using Orders;
using Raven.Client.Documents.Commands;
using Raven.Client.ServerWide;
using Raven.Client.ServerWide.Operations;
using Tests.Infrastructure;
using Xunit;
using Xunit.Abstractions;

namespace SlowTests.Issues
{
    public class RavenDB_16265 : RavenTestBase
    {
        public RavenDB_16265(ITestOutputHelper output) : base(output)
        {
        }

        [RavenFact(RavenTestCategory.Compression)]
        public void ShouldAddCompressedFlagToPageWhenNumberOfOverFlowPagesIsSame_AfterCompressionFromNotCompressed()
        {
            var path = NewDataPath();
            if (Directory.Exists(path))
                Directory.Delete(path, true);
            using (var store = GetDocumentStore(new Options
            {
                Path = path,
                RunInMemory = false
            }))
            {
                var extension = "IGJ6UY5ldhOcdyc20z7nzsykaD2GndaX4uVOac6w8ep0myIsjwZT527Yjr4mxXydeDaddvsqQTRIxykvIYUPYfqJvQxztaZZum4GkYo0bvW1E7IsH3GtDxuXHUoJvLupDtNjK7vPPOR3uTiYXRkawy6I0Y7gAUIwsxKlK3PHbKLL0DkgJfSEc171AgPTLl5VZcFx2WiLuwJrzisIJegow9AS0ZeWi11V6ZnfBNXOMsztY3PvYCDOxKI5EfNzgDMdYPIFpVTGlHz0695Oa1Ys9SQxdlQEK5Wczs8OgZ0JEUaS4khnf0pcZJNOjZawkursWvffnOduAjOLQPqiTSIDYuC9rG9aziBxhCI8yIrkPsAxEO5eR7phsTU7wrDQWaW8KlSrNr8EbgW8EX5nSAGq7Wr114V8fLlVlNb5d6a9rePDI2IJFcnGBM0epJHnItSxBCKFS1ezuHfyXHspNDINLH6YleOsE5uDG51SKqKMBPjYRPcHprRPF9NdfnnNobeh6yTxMdNkPJrQXW2WuW9ZsPr0CVHaYynTyJBpsaI5vnMKwesYR8W9f9lhSArBZ11CSE19e3JrFeo5UzhSWcq058ZNeqjLEEy4sgsoIX8VyPZtxHrRIxh96wU7Ej0fBjKPZkGS5quQ6pUrg7FJDz1NqPwWuKHmXnZaHk9ttTNGmnUYXBBE9ZNnbByEAeUj9GAD8C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7fiUu7hr7Tp3rTnl89OaWEfsx7GJEX8RaI2QGYWbXa7VWnUM6LayY5E8DsI4AjhC1YCLLeQadhAHuIpy7tjZKi3owcAKDTsLcZkE4ihtSl5n9tOFpTCi3Yd7kgYLu8uaaJssUObK2m2O5aji4wmNhXOLPwAsowxqMWrjb2NE9DBlyiUWE8ko8ojZvwJ8YLzW8CmXPJrPOXQv3zuYnfXjR8sndOuj5OTWBE6YdL5cmiiZ3sSAPXTx8P8Eav6SyorTUEQRt089ELBgXpWeCwaYKL4G7HvZXu9U0XijMWDvz2WBKOkLcPM88RPlmQLZR3HNWZ3zMBk6ZuX4umkMOlBgkeVYeq9p1MkXWTMGJi1xkkPtGSBQ6wIkXcjZNQOAAkHmvWraL9DZovSGAfYhVwlGuODFef9LLpIs3q46t5J8WfhiUYGYCcuQXcX2U0Ogpowq70dzIAAdClEIRlxWTC958fEDmnXsVcLbRT1WutIIs4gdT8Xr1gOwr1JmUafz1hp7WbAQJkufs8Y8tkMGL5GbqCZUmzTWy6uxu9X3RXVgRdjulqj1ocQorjXcSXFhtDCOAFe3EDIgQaX3eqvUZf8DtgiRo3F3qkbBBWhQGPnKAabVRlACVFYHfOkqbtAXALB2DZfyywfQrt4DHS98jjfrzV0fWvpyaFzo4Gcza4AYWTNBFATkvVl2BeqwW13iafRUE7uoK7dA2Avzkj9kCFDT7ormoyPK";

                using (var session = store.OpenSession())
                {
                    session.Store(new Employee()
                    {
                        Extension = extension,
                        FirstName = firstName,
                        HomePhone = homePhone,
                        LastName = lastName
                    }, "Employee/322");
                    session.SaveChanges();
                }
                var executor = store.GetRequestExecutor();
                using (var _ = executor.ContextPool.AllocateOperationContext(out var ctx))
                {
                    var cmd = new GetDocumentSizeCommand("Employee/322");
                    executor.Execute(cmd, ctx);
                    Assert.True(cmd.Result.ActualSize <= cmd.Result.AllocatedSize);
                }
                var record = store.Maintenance.Server.Send(new GetDatabaseRecordOperation(store.Database));
                record.DocumentsCompression = new DocumentsCompressionConfiguration(true, "Employees");
                store.Maintenance.Server.Send(new UpdateDatabaseOperation(record, record.Etag));

                using (var session = store.OpenSession())
                {
                    var emp = session.Load<Employee>("Employee/322");
                    emp.Title = "Patched";
                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    var emp = session.Load<Employee>("Employee/322");
                    Assert.Equal("Patched", emp.Title);
                    Assert.Equal(extension, emp.Extension);
                    Assert.Equal(homePhone, emp.HomePhone);
                    Assert.Equal(lastName, emp.LastName);
                    Assert.Equal(firstName, emp.FirstName);
                }
            }
        }
    }
}
